//import { List } from "vant";
import Vue from "vue";
import VueRouter from "vue-router";

//路由懒加载
let Cart = () => import("../views/Cart.vue");
let Cart2 = () => import("../views/Cart2.vue");
let List = () => import("../views/List.vue");
let Home = () => import("../views/Home.vue");
let Sale = () => import("../views/Sale.vue");
let User = () => import("../views/User.vue");
let Login = () => import("../views/Login.vue");
let Reg = () => import("../views/Reg.vue");
let Failed = () => import("../views/Failed.vue");
let Classify = () => import("../views/Classify.vue");
let Show = () => import("../views/Show.vue");
let Details = () => import("../views/Details.vue");
let Search = () => import("../views/Search.vue");
let Address = () => import("../views/Address.vue");
let Order = () => import("../views/Order.vue");
Vue.use(VueRouter);

// 路由表
const routes = [
    {
        path: "/home",
        component: Home,
        name: "home"
    },
    {
        path: "/",
        redirect: "/home"
    },
    {
        path: "/list",
        redirect: "/list/1"
    },
    {
        path: "/list",
        component: List,
        name: "list",
        children: [
            //路由嵌套：子路由
            {
                path: "1",
                name: "list/shoe1",
                component: Classify
            },
            {
                path: "2",
                name: "list/shoe2",
                component: Classify
            },
            {
                path: "3",
                name: "list/shoe3",
                component: Classify
            },
            {
                path: "4",
                name: "list/shoe4",
                component: Classify
            }
        ]
    },
    {
        path: "/sale",
        component: Sale,
        name: "sale"
    },
    {
        path: "/show",
        component: Show,
        name: "show"
    },
    {
        path: "/cart",
        component: Cart,
        name: "cart"
    },
    {
        path: "/cart2",
        component: Cart2,
        name: "cart2"
    },
    {
        path: "/user",
        component: User,
        name: "user",
        //  meta是元信息，可利用设置路由守卫
        meta: {
            ischeck: true //需要路由守卫；
        }
    },
    {
        path: "/login",
        component: Login,
        name: "login"
    },
    {
        path: "/reg",
        component: Reg,
        name: "reg"
    },
    {
        path: "/details",
        component: Details,
        name: "details"
    },
    {
        path: "/Search",
        component: Search,
        name: "search"
    },
    {
        path: "/failed",
        component: Failed,
        name: "failed"
    },
    {
        path: "/address",
        component: Address,
        name: "Address",
        //  meta是元信息，可利用设置路由守卫
        meta: {
            ischeck: true //需要路由守卫；
        }
    },
    {
        path: "/order",
        component: Order,
        name: "order"
    }
];

const router = new VueRouter({
    mode: "history", //history 模式路径就没有#号
    routes
});

export default router;
